Imports Microsoft.VisualBasic
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections.Generic
Imports EntityLayer

Public Class SolicitanteDA

    Public Shared Function BuscarSolicitantexCotizacion(ByVal intIdCotizacion As Integer) As Solicitante

        Dim myConnection As New SqlConnection(ConexionDA.ObtenerCnx)
        Dim myCommand As New SqlCommand("usp_ListSolicitanteByCotizacion", myConnection)
        myCommand.CommandType = CommandType.StoredProcedure

        Dim para As SqlParameter

        para = New SqlParameter("@intIdCotizacion", SqlDbType.Int)
        para.Direction = ParameterDirection.Input
        para.Value = intIdCotizacion
        myCommand.Parameters.Add(para)

        myConnection.Open()

        Dim reader As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)

        Dim rsSolicitante As New Solicitante()

        While reader.Read()
            rsSolicitante.Nombre = reader("Nombre").ToString
            rsSolicitante.Apellido = reader("Apellido").ToString()
            rsSolicitante.Area = reader("Area").ToString()
            rsSolicitante.Telefono = reader("Telefono").ToString()
            rsSolicitante.Email = reader("Email").ToString()
            rsSolicitante.Codigo = reader("CodigoSolictante").ToString()
        End While

        reader.Close()
        myConnection.Close()

        Return rsSolicitante

    End Function

    Public Shared Function ListarTodo() As DataSet
        Dim myConnection As New SqlConnection(ConexionDA.ObtenerCnx)
        Dim myDataadapter As New SqlDataAdapter("COM_Solicitante_ListAll", myConnection)
        myDataadapter.SelectCommand.CommandType = CommandType.StoredProcedure

        Dim ds As New DataSet

        myDataadapter.Fill(ds, "GuiaEntrada")

        Return ds

    End Function
End Class
